﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TTDataAccess;
using TTEntity;
using System.Data;

namespace TTBusiness
{
    public class clsBSSystemLog
    {
        clsDASystemLog objDA = new clsDASystemLog();
        private clsSystemLog getDataFromRow(DataRow dr)
        {
            try
            {
                clsSystemLog obj = new clsSystemLog();
                if (!dr.Equals(null))
                {
                    if (!dr.IsNull("ID"))
                        obj.Id = Convert.ToInt32(dr["ID"]);
                    if (!dr.IsNull("Title"))
                        obj.Title = dr["Title"].ToString();
                    if (!dr.IsNull("Time"))
                        obj.Time = Convert.ToDateTime(dr["Time"]);
                    if (!dr.IsNull("Value"))
                        obj.Value = (float)Convert.ToDouble(dr["Value"]);
                    if (!dr.IsNull("LogTypeID"))
                        obj.LoginTypedId = Convert.ToInt32(dr["LogTypeID"]);
                }
                return obj;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsSystemLog> getAll()
        {
            try
            {

                List<clsSystemLog> objList = new List<clsSystemLog>();
                DataTable dt = new DataTable();
                dt = objDA.GetAll();
                foreach (DataRow dr in dt.Rows)
                {
                    clsSystemLog account = new clsSystemLog();
                    account = getDataFromRow(dr);
                    objList.Add(account);
                }
                return objList;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Insert(clsSystemLog obj)
        {
            try
            {
                objDA.Insert(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Update(clsSystemLog obj)
        {
            try
            {
                objDA.Update(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Delete(int id)
        {
            try
            {
                objDA.Delete(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
